package com.cn.hjsj.appInterface.appImpl;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.cn.hjsj.appInterface.appService.AppEvaluateService;
import com.cn.hjsj.service.IEvaluateService;
import com.cn.hjsj.util.log.LogUtil;

import net.sf.json.JSONObject;
@Component("appEvaluateImpl")
public class AppEvaluateImpl implements AppEvaluateService {
	@Resource(name="evaluateService")
	private IEvaluateService evaluateService;
	@Override
	public Map<String, Object> evaluate(JSONObject object) {
		// TODO Auto-generated method stub
		Map<String, Object> map=new HashMap<String,Object>()
				, maps=new HashMap<String,Object>();
		try{
			maps.put("orderNo", object.getString("orderNo"));
			maps.put("evaluate", object.getInt("evaluate"));
			maps.put("attitudeStar", object.getInt("attitudeStar"));
			maps.put("starMaintenance", object.getInt("starMaintenance"));
			if(object.containsKey("details") && !"".equals(object.containsKey("details"))){
				maps.put("details", object.containsKey("details"));
			}
			int flag = evaluateService.insertSelective(maps);
			if(flag!=0){
				LogUtil.info("/AppEvaluateImpl/evaluate:调用成功");
				map.put("code", "10000");
				map.put("mes", "调用成功,数据更新成功");		
			}else{
				LogUtil.error("/AppEvaluateImpl/evaluate:参数更新失败！");
            	map.put("code", "40001");
                map.put("mes", "将数据更新到数据库中失败");
			}
			return map;
		}catch(Exception e){	
			LogUtil.error("/AppEvaluateImpl/evaluate:解析参数异常！"+e.getMessage());
			map.put("code", "30000");
			map.put("mes", "参数列表初始化错误，可能不是合法的JSON数据格式！");
			return map;
		}
	}

}
